MNT: install contextily with the other optional requirements - #1179
MNT: install contextily with the other optional requirements#1179ting-hong-shieh wants to merge 3 commits into
Conversation
contextily is declared in the monte-carlo extra in pyproject.toml but not
in requirements-optional.txt, and the Makefile's install target reads the
requirements files. test_monte_carlo_plots_background.py opens with
pytest.importorskip("contextily"), so anyone who sets up with `make
install` skips that file: 18 tests, and 53 statements that Codecov counts
as covered.
The workflow installs .[all], so CI already has it and is unaffected. What
this fixes is the local suite silently disagreeing with CI, with a skip
reason as the only clue.
Same specifier as pyproject.toml, including the 3.14 marker.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1179 +/- ##
===========================================
+ Coverage 84.57% 89.96% +5.39%
===========================================
Files 131 131
Lines 17527 17527
===========================================
+ Hits 14824 15769 +945
+ Misses 2703 1758 -945 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR aligns the monte-carlo optional dependency set between pyproject.toml and the documented requirements-file install path, so local installs using the Makefile no longer silently skip contextily-dependent Monte Carlo plotting tests and diverge from CI coverage.
Changes:
- Add
contextily>=1.0.0; python_version < '3.14'torequirements-optional.txtto match themonte-carloextra.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| multiprocess>=0.70 | ||
| statsmodels | ||
| prettytable | ||
| contextily>=1.0.0; python_version < '3.14' |
There was a problem hiding this comment.
Confirmed, and this is what 0e87657a addresses.
Reproduced on develop with contextily installed and outbound sockets blocked:
6 failed, 12 passed in 0.90s
FAILED test_ellipses_background_types_display_successfully[satellite]
FAILED test_ellipses_background_types_display_successfully[street]
FAILED test_ellipses_background_types_display_successfully[terrain]
FAILED test_ellipses_background_types_display_successfully[CartoDB.Positron]
FAILED test_ellipses_background_works_with_custom_limits
FAILED test_ellipses_background_saves_file_successfully
All six come out of the contextily.bounds2img call at monte_carlo_plots.py:166,
surfaced through the generic handler at :198.
Same blocked-socket run on this branch, with the autouse mock_background_tiles
fixture in place:
18 passed in 0.38s
The fixture patches contextily.bounds2img to return a 2x2 zero-valued tile plus the
Web Mercator extent for the requested bounds, so provider resolution, extent handling
and the plotting path are all still exercised — only the tile server is gone. Wall
clock for the file went from 37s to under half a second.
Verified on Python 3.12.3, contextily 1.7.1. tests/unit/simulation is 191 passed,
4 skipped; pylint on the changed file is 10.00/10.
|
@Gui-FernandesBR heads-up before you merge: your approval landed at 02:37 on the 19th, Worth a second look at that commit specifically. The requirements line is unchanged from |
The gap
contextilyis declared in themonte-carloextra inpyproject.toml:but not in
requirements-optional.txt, and that is what the documented setup installs:tests/unit/simulation/test_monte_carlo_plots_background.pyopens withpytest.importorskip("contextily"), so the whole file is skipped.What it costs
Measured at
4263fa95d7fe6f63d9593f01e4ff7a088369e195, running the five steps oftest_pytest.yamlin order with--cov-append:contextilyplots/monte_carlo_plots.pyCodecov reports 84.57% for that commit, and 14,824 hits against 2,703 misses. The second row is the one that matches; the first is what a contributor following the Makefile sees.
Testsinstalls.[all], which does resolve the extra on Python 3.10, so CI is unaffected either way. What this fixes is a local run quietly disagreeing with CI by 53 statements, with a skip reason buried in-rsoutput as the only clue.The change
One line, the same specifier as
pyproject.toml, marker included:Verification
Before, in an environment built from the requirements files:
After installing it:
Those 18 do reach the network — they call
contextily.bounds2imgagainst real tile providers rather than stubbing it. That is existing behavior and not changed here, but it is worth knowing that this makes the default local suite contact Esri, OpenStreetMap and CartoDB where it previously did not. Happy to close this instead if the team would rather those tests were stubbed first, or would rather keep them opt-in.Found while re-measuring the baseline for #709; it is why the figures in my first comment there were 53 statements low.